package com.ziq.base.service

import android.os.Parcel
import android.os.Parcelable
import java.util.*

class ConnectInfo() : Parcelable {

    var url:String = ""
    var uid:Int = 0
    var roomId:Int = 0
    var platform:String = "app"
    var accepts: Array<Int> = arrayOf(1000)

    constructor(parcel: Parcel) : this() {
        url = parcel.readString()?:""
        uid = parcel.readInt()
        roomId = parcel.readInt()
        platform = parcel.readString()?:"app"
        val array = parcel.readArray(Int.Companion::class.java.classLoader)?: arrayOf()
        accepts = Arrays.copyOf(array, array.size, Array<Int>::class.java)
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(url)
        parcel.writeInt(uid)
        parcel.writeInt(roomId)
        parcel.writeString(platform)
        parcel.writeArray(accepts)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<ConnectInfo> {
        override fun createFromParcel(parcel: Parcel): ConnectInfo {
            return ConnectInfo(parcel)
        }

        override fun newArray(size: Int): Array<ConnectInfo?> {
            return arrayOfNulls(size)
        }
    }
}